package com.ljq.rpc.server.condition;

import com.ljq.rpc.server.config.ServerConfig;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class ServerCondition implements Condition {
    private static String property;

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        if(property==null){
            Environment environment = context.getEnvironment();
            property = environment.getProperty("rpc.job");
        }
        return property.equals("server");
    }

}
